﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WorkStation.Frameworks.EasyBus.DbModel
{
    /// <summary>
    /// 监听信息
    /// </summary>
    [Serializable]
    public class ListenerInfo
    {
        protected int _processThreadCount { get; set; }

        /// <summary>
        /// 监听器名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 处理消息线程数
        /// </summary>
        public int ProcessThreadCount 
        {
            get 
            {
                if (this._processThreadCount == 0) { return 1; }

                return this._processThreadCount;
            }
            set 
            {
                this._processThreadCount = value;
            }
        }

        /// <summary>
        /// 监听终结点名称
        /// </summary>
        public string Mq { get; set; }

        /// <summary>
        /// 订阅端总线名称
        /// </summary>
        public string SubBusName { get; set; }

        /// <summary>
        /// 服务器负载节点名称
        /// </summary>
        public string NodeName { get; set; }

        /// <summary>
        /// 处理信息
        /// </summary>
        public ProcessInfo Process { get; set; }

        /// <summary>
        /// 是否启用 （默认启用）
        /// </summary>
        public bool Enabled { get; set; }

        public ListenerInfo() 
        {
            this.Enabled = true;
        }
    }
  
    /// <summary>
    /// 处理信息
    /// </summary>
    [Serializable]
    public class ProcessInfo 
    {
        /// <summary>
        /// 处理器名称
        /// </summary>
        public string[] HandleName { get; set; }

        /// <summary>
        /// 路由关键字
        /// </summary>
        public string RouteKey { get; set; }
    }
}
